
package org.esir.base.android.broadcast;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;


/**
 * NetworkStatusReceiver用来监听设设备状态变化（网络，电池，屏幕,开关机等）
 *
 * @author 黄嵘才(HuangRc)
 * @date 2017/9/5 0005
 */

public class StatusReceiver extends BroadcastReceiver {
    private static String TAG = "StatusReceiver";

    @Override
    public void onReceive(Context context, Intent intent) {
        Log.i(TAG, "状态发生变化");
        if (intent == null) {
            return;
        }
        String action = intent.getAction();

        if ("android.net.conn.CONNECTIVITY_CHANGE".equals(action)) {
            //处理 网络状态变更
            //*检查网状态，向应用发送通知
            notifyStatusChanged();
        }

    }

    private void notifyStatusChanged() {
        StatusManager.notifyStatus();
    }

}
